import unittest
import requests


class MyTestCase(unittest.TestCase):
    def test_vbuluo_login(self):
        '''V部落登录接口练习_data方式练习'''
        login_date={'username':'sang','password':123}
        login_headers={'Content-Type':'application/x-www-form-urlencoded'}
        login=requests.post('http://182.92.178.83:8081/login',data=login_date,headers=login_headers,timeout=2)
        # print(login.json())
        back=login.json()
        #下边是断言，这里断言status和msg
        self.assertEqual(back['status'],'success')
        self.assertEqual(back['msg'],'登录成功')
    def test_exam_login(self):
        '''考试系统后台登录_json方式练习'''
        date={'password':123456,'userName':'admin','remember':'true'}
        head={'Content-Type':'application/json'}
        login=requests.post('http://101.200.61.210:8081/api/user/login',json=date,headers=head,timeout=2)
        # print(login.json())
        back=login.json()
        # 下边开始断言
        self.assertEqual(back['code'],1)
        self.assertEqual(back['message'],'成功')

if __name__ == '__main__':
    unittest.main()
